#ifndef _BUOLA_SCENE_TRANSFORM_CRIGIDBODY_H_
#define _BUOLA_SCENE_TRANSFORM_CRIGIDBODY_H_

#include <buola/scene.h>
#include <buola/scene/ctransform.h>
#include <buola/scene/cgeode.h>
#include <buola/mat.h>
#include <BulletDynamics/Dynamics/btRigidBody.h>

namespace buola { namespace scene {

typedef std::unique_ptr<btRigidBody> PBulletRigidBody;

class CRigidBody : public CTransform, public btMotionState
{
public:
    CRigidBody(PGeode pGeode,double pMass,const mat::CMat34d &pPos);
    ~CRigidBody();

    const PBulletRigidBody &GetBulletBody()    {   return mBody;   }
    const PGeode &Geode()                       {   return mGeode;  }
    mat::CVec3d CenterOfMass()  {   return mLocalTransform(nAll,3); }
    
private:
    void CalcLocalTransform() override;
    void getWorldTransform(btTransform &pT) const override;
    void setWorldTransform(const btTransform& pT) override;
    
private:
    PGeode mGeode;
    PBulletRigidBody mBody;
    PBulletCollisionShape mCollisionShape;
};

/*namespace scene*/ } /*namespace buola*/ }

#endif
